/*
 * =====================================================================================
 *
 *       Filename:  LcdControl.h
 *
 *    Description:  this is a pthread to deal lcd and button
 *
 *        Version:  1.0
 *        Created:  2011年11月17日 11时12分51秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  YOUR NAME (), 
 *        Company:  
 *
 * =====================================================================================
 */
#ifndef CLCDCONTROL_H
#define CLCDCONTROL_H

#include "CLcd.h"
#include "publicFun.h"
#include "AliveServer.h"


class CLcdControl:public AliveServer
{
public:
	CLcdControl();
	~CLcdControl();
	void SetStop(bool bStop);
	
	void GetTime();
	void ShowFaMenu();
	void Service();
	
private:
	void ControlLcd();
	void InitLcdHzkBtn();
	bool PwdIsTrue(bool isChgPwd=false);
	bool IsConfir();
	bool IsChangeVaule(EChargeOpt curType, float *curVaule);
	bool IsChangeVaule(EChargeOpt curType, int *curVaule);
	bool IsChangeVaule(ESetAcDcAddr curType, char *curVaule);
	bool IsSetTerOpt(ETerOpt curType,int *curVaule);
	bool IsChangeBatAddr(int *curVaule);
	bool IsSetIPAddr(char *buf);
	void InputNewPwd(bool reChgPwd=false,char *cpKeyBuf=NULL);
	void CheckUpSideBit(int xoffset,int startBit, int endBit,char *buf);
	void CheckDownSideBit(int xoffset,int startBit, int endBit,char *buf);
	void ShowLocalTime();
	void SetDcBaud(int curBaud);
	void SetDcChkSumBit(EChkSumBit ckBit);
	void SetDcDatBit(EDataBit datBit);
	void SetDcStopBit(EStopBit stopBit);
    void SetAcBaud(int curBaud);
	void SetAcChkSumBit(EChkSumBit ckBit);
	void SetAcDatBit(EDataBit datBit);
	void SetAcStopBit(EStopBit stopBit);
	void ProcPgAlarmLog();
	void PressUp();
	void PressDown();
	void PressEsc();
	//void PressEnter();

	void SetBatModuleInfoMenu();
    void SetBatBoxManageMenu();
    void SetAlarmLogMenu();
    void ShowAboutMenu();
    void Show2ndMenu(int &yoffset);
    void ShowDevSta_ChargeTypeMenu(int &yoffset);
    void ShowChargeTypeMenu(int &yoffset);
    void ShowChargeVMenu();
    void ShowChargeLimtVMenu();
    void ShowChargeLimtAMenu();
    void ShowChargeLimtTimeMenu();
    void ShowAcDcCfgMenu(bool isDcCfg,int &yoffset);
    void ShowChangeTermAddrMenu();
    void ShowTermComParaMenu(int &yoffset);
    void ShowBatModuleAddrMenu(int &yoffset);
    void ShowBatBoxComParaMenu(int &yoffset);
    void ShowTermIPMenu();
    void ShowChangePwdMenu();
    void ShowResetMenu();
    void ShowGetLocalTimeMenu();
    void ShowVersionMenu(int &yoffset);
    void ShowMaxOutputMenu(int &yoffset);
    void MenuSetTermStatus(EDevSta status);
    void MenuSetChargeType(EChrgType chrgType);
    void MenuSetDcAddr();
    void MenuSetAcAddr();
    void MenuSetServerComRate(EServerComRate rate);
    void ShowBatBoxComTypeMenu(int &yoffset);
    void ShowDcSetCfgMenu(EDcAcCfgNum num,int &yoffset);
	void ShowAcSetCfgMenu(EDcAcCfgNum num,int &yoffset);
	void MenuSetBatModAddr(int item);
	void ShowBatBoxComRateMenu(int &yoffset);
	void MenuSetBatBoxComType(EBatBoxComType comType);
	void MenuSetBatBoxComRate(EBatBoxComRate comRate);
	void MenuSetDcAcOtherBaud(EDcOrAc curDev);
	void ShowNext2ndMenu(int &yoffset);
	void CheckTerminalInfo(int &yoffset);
	void MenuSetDcAcFirstItemCfg();
	void MenuSetDcAcSecondItemCfg();
	void MenuSetDcAcThirdItemCfg();
	void BackToFirstMenu();
	void BackToSecondMenu();
	void BackToThirdMenu();
	void BackToShowSetDcAcCfgMenu();
	void BackToBatBoxComCfgMenu();
	
	volatile bool isStop;
	bool hasRecd;
	bool mAddFrameFlag;
	CLcd lcd;
    unsigned char mKey;
	volatile time_t mOldPwdTime;
	volatile time_t mNewPwdTime;
	volatile time_t mLightNewTime;
    volatile time_t mLightOldTime;
	int mPwdInterval;
	int mCurItem;
    int mCurFrame;
    int mPreFaItem;
    int mPreSonItem;
    int mPreGrsonItm;
    int mPreGrsonItmEx;
    int mCurMaxItem;
    int mCurLogIndex;
};

#endif
